<?php global $cv_option; ?>
				<div id="trending-story" class="clearfix">
					<?php 
					$i = 0;
					//$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
					if(is_home())
						$key = '_meters_trending_story';
					else
						$key = '_meters_featured_story';
					$args = array(							
						'meta_query' => array(
							array(
								'key' => $key,
								'value' => 'on',
								'compare' => 'LIKE')								
						),
						'showposts' => 8
					);
					if(is_home()) 
						$title = $cv_option['trendingstory_title']; 
					else 
						$title = $cv_option['featuredstory_title'];
					query_posts($args);
					if(have_posts()) : while (have_posts()) : the_post(); $i++; 
						if($i==1) { ?>
							<div class="trending-1">
								<h3 class="title-small"><span><?php echo $title; ?></span></h3>
								<div class="hentry">
					
									<div class="entry-img">
										<?php if ( current_theme_supports( 'get-the-image' ) ) {
										
												$thumb2 = get_the_image( array( 'format' => 'array', 'echo' => false, 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => 'trending-1-thumb', 'default_image' => get_bloginfo ( 'template_url' ) . '/images/'. 'trending-1-thumb.gif') );  
												
												if(!empty($thumb2['src'])) { ?>
													<a href="<?php echo esc_url(get_permalink());?>"></a>	
													<img src="<?php echo $thumb2['src'];?>">												
												<?php } 											
										} ?>						
									</div><!-- .hentry-img -->		
									
									<?php if($cv_option['sc_disable_socials'] != true) { ?>
										<div class="social-media"><?php echo cv_wpsocialite_markup('small', 3); ?></div>
									<?php } ?>
									<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>	
									
									<div class="entry-content">
										<?php 
										//Get all terms associated with post in taxonomy 'category'
										$terms = get_the_terms(get_the_ID(),'category');
													
										//Get an array of their IDs
										$term_ids = wp_list_pluck($terms,'term_id');

										//Get array of parents - 0 is not a parent
										$parents = array_filter(wp_list_pluck($terms,'parent'));

										//Get array of IDs of terms which are not parents.
										$term_ids_not_parents = array_diff($term_ids,  $parents);

										//Get corresponding term objects
										$terms_not_parents = array_intersect_key($terms,  $term_ids_not_parents);
										//echo $terms_not_parents; 
										echo '<span class="category">';
										$i = 0;
										foreach($terms_not_parents as $t) {										
											$i++;
										?>
											<a href="<?php echo get_term_link($t->slug, 'category');?>"><?php echo $t->name;?></a>
										<?php 
											if($i==1)
												break;
										}
										echo '</span>';
										?>
										
										<?php print_excerpt(250); ?>																				
									</div>
									
									<div class="entry-meta">						
										<span class="date">
											<?php echo get_the_time('M jS Y');?> 					
										</span>						
										<?php 
										echo apply_atomic_shortcode( 'entry_meta', __( 'by [entry-author]', hybrid_get_textdomain() ) ); ?>
										<span class="comments-link">
											<a class="comments-number" href="<?php echo get_comments_link();?>" ><?php echo get_comments_number() . ' ' . __( 'Comments', hybrid_get_textdomain() );?></a>			
										</span>	
									</div>	<!-- .entry-meta -->
								
								</div><!-- .hentry -->
							</div><!-- .trending-1 -->
						<?php	
						}
						else if($i == 2) { ?>
							<div class="trending-story-right">				
								<div class="trending-2 clearfix">					
									<h3 class="title-small"><span><?php _e("More", hybrid_get_textdomain());?> <?php echo $title; ?></span></h3>
									<div class="hentry clearfix">
										<div class="entry-img">
										<?php if ( current_theme_supports( 'get-the-image' ) ) {
										
												$thumb2 = get_the_image( array( 'format' => 'array', 'echo' => false, 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => 'entry-image-thumb', 'default_image' => get_bloginfo ( 'template_url' ) . '/images/'. 'entry-image-thumb.png') );  
												
												if(!empty($thumb2['src'])) { ?>
													<a href="<?php echo esc_url(get_permalink());?>"><img src="<?php echo $thumb2['src'];?>"></a>													
												<?php } 											
										} ?>						
										</div><!-- .hentry-img -->		
										
										<div class="title">
							
											<a href="<?php echo get_permalink(); ?>" class="entry-title"><?php echo the_title(); ?></a>
											<span class="comments-link"><a href="#"><?php echo get_comments_number();?></a></span>
											<?php if($cv_option['sc_disable_socials'] != true) { ?>
												<div class="social-media"><?php echo cv_wpsocialite_markup('small', 2); ?></div>
											<?php } ?>
										</div>
										
										
									</div><!-- .hentry -->
									<div class="clear"></div>
						<?php			
						}
						else if($i == 3) { ?>
									<div class="hentry clearfix">
										<div class="entry-img">
										<?php if ( current_theme_supports( 'get-the-image' ) ) {
										
												$thumb2 = get_the_image( array( 'format' => 'array', 'echo' => false, 'custom_key' => array( 'Thumbnail', 'thumbnail' ), 'default_size' => 'entry-image-thumb', 'default_image' => get_bloginfo ( 'template_url' ) . '/images/'. 'entry-image-thumb.png') ); 
												
												if(!empty($thumb2['src'])) { ?>
													<a href="<?php echo esc_url(get_permalink());?>"><img src="<?php echo $thumb2['src'];?>"></a>													
												<?php } 											
										} ?>						
										</div><!-- .hentry-img -->		
									
											<div class="title">
							
											<a href="<?php echo get_permalink(); ?>" class="entry-title"><?php echo the_title(); ?></a>
											<span class="comments-link"><a href="#"><?php echo get_comments_number();?></a></span>
											<?php if($cv_option['sc_disable_socials'] != true) { ?>
												<div class="social-media"><?php echo cv_wpsocialite_markup('small', 2); ?></div>
											<?php } ?>
										</div>
										
										
									</div><!-- .hentry -->
								</div><!-- .trending-2 -->
						<?php }
						else if($i == 4) { ?>
								<div class="trending-3">
					
									<h3 class="title-small"><span><?php _e("More...", hybrid_get_textdomain());?></span></h3>									
									<div>
										<a class="clearfix" href="<?php echo get_permalink(); ?>"><?php echo the_title(); ?></a>
						<?php }
						else if($i >4) { ?>
										<a class="clearfix" href="<?php echo get_permalink(); ?>"><?php echo the_title(); ?></a>
						<?php
						}
						
					
					endwhile; ?>						
					<?php endif; ?>
					<?php wp_reset_query(); 
					
					if($i>=4) echo '</div></div><!-- .trending-3 --></div><!-- .trending-story-right -->';
					elseif($i>1) echo '</div><!-- .trending-2 --></div><!-- .trending-story-right -->';					
					?>	
				</div><!-- #trending-story -->			
				